-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: rolling with MSVC 2017 build #21813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
appveyor.yml
Outdated
PYTHON_VERSION: "3.7" | ||
PYTHON_ARCH: "64" | ||
CONDA_PY: "37" | ||
CONDA_NPY: "113" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you make this 114?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this also very likely won't work, very little is built for 3.7 :<
The |
Codecov Report
@@ Coverage Diff @@
## master #21813 +/- ##
==========================================
+ Coverage 91.99% 92% +<.01%
==========================================
Files 167 170 +3
Lines 50578 50553 -25
==========================================
- Hits 46530 46510 -20
+ Misses 4048 4043 -5
Continue to review full report at Codecov.
|
Well, good news is we got a repro of this on our CI - it's not a python 3.7 issue, but instead a Visual Studio 2017 one. Still not convinced this isn't a compiler bug, but having trouble to get a simple case to reproduce - one option would be to build our wheels VS 2015 - but annoying, b/c python forces the newest version, so can't have 2017 installed. I'll keep trying some things. |
This is kind of horrible, but it does fix the problem (just a lint issue I pushed for) and I'm out of ideas - any thoughts or suggestions @jreback, @TomAugspurger ? |
@@ -654,16 +654,21 @@ cdef inline void add_var(double val, double *nobs, double *mean_x, | |||
double *ssqdm_x) nogil: | |||
""" add a value from the var calc """ | |||
cdef double delta | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doing
if val != val:
return
# rest of code
might work (and be more clear here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great suggestion, sadly didn't work
@chris-b1 could you summarize the issue? You think MSVC is just optimizing away |
That's right, optimizing maybe not the right word, but somehow the And yes, |
Ok, thanks... @jjhelmus do we know anyone at Microsoft who works on their compilers that might be able to provide insight on #21813 (comment) and #21813 (comment)? |
@zooba might be able to connect you to the right team at Microsoft |
I can try, but I haven't been having as much luck recently. Since this is Cython, can someone post the generated code for the comparison? There's a much better chance of getting something useful if they're looking at the code they actually compile, and not the code someone else is compiling. |
It's Cython, so of course the bigger file is a tangled mess, but the particular function is easy to read - lines of gist here. Called in a few places, but for instance, here is a problem one. Cython isn't doing anything particular interesting - it's a I can post it later, not on this machine, but I've also tried to write a simpler, plain c++ example that triggers the problem, but it always worked - really not sure why. |
I can reproduce it with this snippet (has a few tricks to try and defeat optimisations, but they are likely unnecessary): #include <math.h>
#include <stdio.h>
double get_value(int i) {
return i > 1 ? NAN : 7;
}
int check_default(double v1, double v2) {
return ((v1 == v2) != 0);
}
#pragma float_control(precise, off, push)
int check_fast(double v1, double v2) {
return ((v1 == v2) != 0);
}
#pragma float_control(pop)
int main(int argc, char **argv) {
double x1 = get_value(argc);
double x2 = get_value(argc);
fprintf(stdout, "default: %d\nfast: %d\n",
check_default(x1, x2), check_fast(x1, x2)
);
} The comparison doesn't behave properly when you disable precise floating point operations. You may be doing this in the build with So I'd guess you need to update the compiler flags for this one, or possibly add an explicit |
Is the MSVC info something that can be inferred from platform.uname (at compile-time)? |
Thanks for taking a look at this @zooba - unfortunately that's not exactly the same problem I'm seeing here, the compiled code is acting as if |
Interestingly using |
Do you have a disassembly showing this? This would be very strange to see as a compiler optimization (unless you mean
Just saw this while rereading the thread. If you start with all the tools on PATH and set |
Could this SO answer be relevant? https://stackoverflow.com/questions/8200311/checking-for-nan-in-cython/20031818#20031818 |
@zooba - do you know how to pull symbols into the dissambly from a
|
Answering my own question - I was missing |
Alright @zooba - I think I have this to a reasonable bit of a dis-assembly - pushing the bounds of my knowledge but looks like a code-generation bug. Here's MSVC 2015 (printfs surround a call to And here is MSVC 2017. The function call doesn't get inlined - half of the NaN check gets done ( |
@chris-b1 Yep, you're absolutely right. Thanks for tracking that down, I'll pass it on! |
Here is the public side of the report: https://developercommunity.visualstudio.com/content/problem/294290/incorrect-codegen-for-double-equality.html Feel free to add pings there whenever you like |
Thanks @zooba! and thanks @jbrockmendel - that's what I'll have to do to fix the 2.7 build, more modern MSVCs are basically standards compliant and have |
does using the fix proposed in #21940 help here? e.g. |
It does (latest commit has that and is passing on appveyor) - but less sure we want to apply that universally, I'll try perf on @jbrockmendel PR later, suspect it may be worse on Windows. |
@chris-b1 this looks good. can you rebase once more. perf looks ok? (even if its slightly worse this is a bug :>) Go ahead and merge on green. |
@jreback thanks, yeah perf will be fine, just slightly slower on Windows for this particular function |
There seem to be a conflict, please backport manually |
* master: BENCH: asv csv reading benchmarks no longer read StringIO objects off the end (pandas-dev#21807) BUG: df.agg, df.transform and df.apply use different methods when axis=1 than when axis=0 (pandas-dev#21224) BUG: bug in GroupBy.count where arg minlength passed to np.bincount must be None for np<1.13 (pandas-dev#21957) CLN: Vbench to asv conversion script (pandas-dev#22089) consistent docstring (pandas-dev#22066) TST: skip pytables test with not-updated pytables conda package (pandas-dev#22099) CLN: Remove Legacy MultiIndex Index Compatibility (pandas-dev#21740) DOC: Reword doc for filepath_or_buffer in read_csv (pandas-dev#22058) BUG: rolling with MSVC 2017 build (pandas-dev#21813)
cc @chris-b1 do you want to see if you can backprot to 23.x branch? |
* Appveyor 3.7 * ci package list * change image type * try hack fix * lint * use isnan on problem function * use numpy compat isnan * use right isnan * work around OSX math undefs * cleanup const * fix reversion * ... (cherry picked from commit 7a2fbce)
* Appveyor 3.7 * ci package list * change image type * try hack fix * lint * use isnan on problem function * use numpy compat isnan * use right isnan * work around OSX math undefs * cleanup const * fix reversion * ... (cherry picked from commit 7a2fbce)
* Appveyor 3.7 * ci package list * change image type * try hack fix * lint * use isnan on problem function * use numpy compat isnan * use right isnan * work around OSX math undefs * cleanup const * fix reversion * ...
git diff upstream/master -u -- "*.py" | flake8 --diff
For now just trying 3.7 on appveyor, not sure if all necessary conda packages are there